

import 'package:flutter/material.dart';
import 'package:hello/douban/modal/home.dart';
import 'package:hello/douban/pages/home/home_movie_item.dart';
import 'package:hello/douban/service/api/home_request.dart';

class HomeContent extends StatefulWidget {
  const HomeContent({Key key}) : super(key: key);

  @override
  _HomeContentState createState() => _HomeContentState();
}

class _HomeContentState extends State<HomeContent> {
  final List<MovieItem> movies = [];
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  //  发送网络请求
    HomeRequest.getMovieList(0).then((res){
      setState(() {
        movies.addAll(res);
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: movies.length,
        itemBuilder: (ctx,index){
      return HomeMovieItem(movies[index],index);
    });
  }
}
